<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('供应商信息列表')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                供应商期数：<select id="supplierNperId" name="supplierNperId" class="form-control">
                                <option th:each="qishu : ${suppliers}" th:text="${qishu['title']}" th:value="${qishu['supplierNperId']}" th:field="*{qishu.title}"></option>
                            </select>
                            </li>
                            <li>
                                <label>名称：</label>
                                <input type="text" name="supplierName"/>
                            </li>

                            <li>
                                <label>法人手机：</label>
                                <input type="text" name="supplierMoble"/>
                            </li>
                            <li>
                                <label>联系人：</label>
                                <input type="text" name="inkman"/>
                            </li>
                            <li>
                                <label>电话：</label>
                                <input type="text" name="moble"/>
                            </li>


                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="resetPre()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="add()" shiro:hasPermission="system:supplier:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:supplier:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:supplier:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:supplier:export">
                    <i class="fa fa-download"></i> 导出
                </a>
                <a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="system:purchasingunit:export">
                    <i class="fa fa-upload"></i> 导入
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:supplier:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:supplier:remove')}]];
        var resetPwdFlag = [[${@permission.hasPermi('system:supplier:resetPwd')}]];
        var prefix = ctx + "system/supplier";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add/{id}",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                importUrl: prefix + "/importData",
                importTemplateUrl: prefix + "/importTemplate",
                queryParams: queryParams,
                modalName: "供应商信息",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'supplierId',
                    title: '供应商ID',
                    visible: false
                },
                {
                    field: 'supplierNperId',
                    title: '供应商期数',
                    visible: false
                },
                {
                    field: 'supplierName',
                    title: '供应商名称'
                },
                    {
                        field: 'supplierPerson',
                        title: '供应商法人姓名'
                    }
                ,
                {
                    field: 'supplierMoble',
                    title: '法人手机'
                },
                {
                    field: 'inkman',
                    title: '联系人'
                },
                {
                    field: 'telephone',
                    title: '联系人电话'
                },
                {
                    field: 'account',
                    title: '供应商账号'
                },
                {
                    field: 'address',
                    title: '供应商地址'
                },
                {
                    field: 'moble',
                    title: '供应商手机联系方式'
                },
                    {
                        field: 'createTime',
                        title: '创建时间'
                    },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="grant(\'' + row.supplierId + '\')"><i class="fa fa-edit"></i>货物授权</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.supplierId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.supplierId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        actions.push("<a class='btn btn-default btn-xs " + resetPwdFlag + "' href='javascript:void(0)' onclick='resetPwd(" + row.supplierId + ")'><i class='fa fa-key'></i>重置密码</a> ");
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function queryParams(params) {
            var search = $.table.queryParams(params);
            search.supplierNperId = $("#supplierNperId").val();

            return search;
        }
        /*数据-新增供货商*/
        function add() {
            var supplierNperId = $("#supplierNperId option:selected").val();

            $.operate.add(supplierNperId);
        }

        function resetPre() {
            $.form.reset();
            $("#supplierNperId").val($("#supplierNperId").val()).trigger("change");

        }
        /* 供应商管理-重置密码 */
        function resetPwd(supplierId) {
            var url = prefix + '/resetPwd/' + supplierId;
            $.modal.open("重置密码", url, '800', '300');
        }
        /* 供应商管理-重置密码 */
        function grant(id) {
            var url = '/system/goodsclassification/listdetail/'+id ;
            $.modal.open("货物授权", url);
        }

    </script>
</body>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <div class="mt10 pt5">
                <input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在，更新这条数据。"> 是否更新已经存在的用户数据
                &nbsp;	<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
</html>